#ifndef _JIAJIA_WORD_H
#define _JIAJIA_WORD_H

#define JIAJIA_WORD_QUEUE_SIZE 1024

#define _JiaJia_word_meminit_once(jjword)       \
    do{                                         \
        (jjword)->word = _JiaJiaLmcc_word_err;  \
        (jjword)->rows = 1;                     \
        (jjword)->cols = 1;                     \
        Yu_string_init(&(jjword)->text);        \
    }while(0)

#define _JiaJia_word_queue_meminit_once(queue)  \
    do{                                         \
        (queue)->head = 0;                      \
        (queue)->tail = 0;                      \
    }while(0)

#define JiaJia_word_init(w) (JiaJia_word_meminit((w), sizeof(JiaJia_word_t)))
#define JiaJia_word_free(w) (JiaJia_word_memfree((w), sizeof(JiaJia_word_t)))

#define JiaJia_word_queue_init(q) (JiaJia_word_meminit((q), sizeof(JiaJia_word_queue_t)))
#define JiaJia_word_queue_free(q) (JiaJia_word_memfree((q), sizeof(JiaJia_word_queue_t)))

typedef struct JiaJia_word{
    int16_t word;
    uint32_t rows;
    uint32_t cols;
    Yu_string_t text;
} JiaJia_word_t, *JiaJia_word_pt;

typedef struct JiaJia_word_queue{
    uint32_t head;
    uint32_t tail;
    JiaJia_word_t buf[JIAJIA_WORD_QUEUE_SIZE];
} JiaJia_word_queue_t, *JiaJia_word_queue_pt;

extern void JiaJia_word_meminit(void *, size_t);
extern void JiaJia_word_memfree(void *, size_t);

extern void JiaJia_word_queue_meminit(void *, size_t);
extern void JiaJia_word_queue_memfree(void *, size_t);

extern void JiaJia_word_queue_in(JiaJia_word_queue_pt);
extern void JiaJia_word_queue_out(JiaJia_word_queue_pt);

extern int16_t JiaJia_word_accept(int16_t);
extern int16_t JiaJia_next_word();

/* extern int16_t JiaJia_word_add(int16_t); */
/* extern int16_t JiaJia_word_sub(int16_t); */
/* extern int16_t JiaJia_word_mult(int16_t); */
/* extern int16_t JiaJia_word_dev(int16_t); */

/* extern int16_t JiaJia_word_assign(int16_t); */
/* extern int16_t JiaJia_word_link(int16_t); */

/* extern int16_t JiaJia_word_eq(int16_t); */
/* extern int16_t JiaJia_word_ne(int16_t); */
/* extern int16_t JiaJia_word_lt(int16_t); */
/* extern int16_t JiaJia_word_gt(int16_t); */
/* extern int16_t JiaJia_word_le(int16_t); */
/* extern int16_t JiaJia_word_ge(int16_t); */

/* extern int16_t JiaJia_word_lparen(int16_t); */
/* extern int16_t JiaJia_word_rparen(int16_t); */
/* extern int16_t JiaJia_word_lbracket(int16_t); */
/* extern int16_t JiaJia_word_rbracket(int16_t); */
/* extern int16_t JiaJia_word_lbrace(int16_t); */
/* extern int16_t JiaJia_word_rbrace(int16_t); */

/* extern int16_t JiaJia_word_comma(int16_t); */
/* extern int16_t JiaJia_word_dot(int16_t); */
/* extern int16_t JiaJia_word_colon(int16_t); */
/* extern int16_t JiaJia_word_semicolon(int16_t); */

/* extern int16_t JiaJia_word_at(int16_t); */
/* extern int16_t JiaJia_word_dun(int16_t); */

/* extern int16_t JiaJia_word_and(int16_t); */
/* extern int16_t JiaJia_word_or(int16_t); */

/* extern int16_t JiaJia_word_true(int16_t); */
/* extern int16_t JiaJia_word_false(int16_t); */

/* extern int16_t JiaJia_word_de(int16_t); */
/* extern int16_t JiaJia_word_shi(int16_t); */
/* extern int16_t JiaJia_word_fou(int16_t); */

/* extern int16_t JiaJia_word_shifoueq(int16_t); */
/* extern int16_t JiaJia_word_shifoune(int16_t); */
/* extern int16_t JiaJia_word_shifoult(int16_t); */
/* extern int16_t JiaJia_word_shifougt(int16_t); */
/* extern int16_t JiaJia_word_shifoule(int16_t); */
/* extern int16_t JiaJia_word_shifouge(int16_t); */

/* extern int16_t JiaJia_word_if(int16_t); */
/* extern int16_t JiaJia_word_elif(int16_t); */
/* extern int16_t JiaJia_word_else(int16_t); */
/* extern int16_t JiaJia_word_loop(int16_t); */
/* extern int16_t JiaJia_word_until(int16_t); */
/* extern int16_t JiaJia_word_loopfactor(int16_t); */
/* extern int16_t JiaJia_word_break(int16_t); */
/* extern int16_t JiaJia_word_continue(int16_t); */

#endif
